﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Ext.Net;
using Sharp.Portal.Mvc;
using Sharp.WebBooter.Areas.Demo.Models;
using Sharp.WebBooter.Areas.Platform.Controllers;
using PartialViewResult = Ext.Net.MVC.PartialViewResult;

namespace Sharp.WebBooter.Areas.Demo.Controllers
{
    [AutomaticTemplate]
    public class DefaultController : Controller
    {
        /// <summary>
        /// 控件展示
        /// </summary>
        /// <returns></returns>
        public async Task<ActionResult> Control(string containerId)
        {
            //return new PartialViewResult
            //{
            //    ViewName = "test",
            //    ContainerId = containerId,
            //    RenderMode = RenderMode.AddTo
            //};
            var vm = new ControlModel()
            {
                UI = {OpenWith = Portal.OpenWith.Tile2Column}
            };
            vm.Phone = "13849958585";
            vm.DateA = DateTime.Parse("2017-01-01");
            vm.Email = "test@abc.com";
            vm.Currency = "1.34";
            vm.ImageUrl = "//www.baidu.com/img/bd_logo1.png";
            vm.GenderCode = "01";
            vm.OrgIdDataSource = await OrgController.OrgTree();



            return new PartialViewResult
            {
                Model = vm,
                ContainerId = containerId,
                RenderMode = RenderMode.AddTo
            };
        }

        public ActionResult RenderWindow()
        {
            return new Ext.Net.MVC.PartialViewResult
            {
                ViewName = "Window",
                Model = new GroupIndexModel()
            };
        }
    }
}